#!/bin/sh
goto bat

cd `dirname $0`

tid=$1
name=$2
type=$3
description=$4
post=${name}-${tid}-${type}
echo  \{\"from\":\"btinfra_sgmanagerService@T00\"\,\"fromName\":\"btinfra_sgmanagerService\"\,\"to\":[\"${tid}\"]\,\"msgType\":\"3\"\,\"ttl\":\"436800\"\,\"severity\":0\,\"taskType\":\"${type}\"\,\"taskId\":\"${name}\"\,\"title\":\"${description}\"\,\"content\":\"${description}\"\} >${post}.utf8
if [ "${BTInfra_T00_S01_btinfra_bugletService}" == "" ] ; then
   BTInfra_T00_S01_btinfra_bugletService=127.0.0.1:30060
fi

wget -O ${post}.response -S  --post-file=${post}.utf8 "--header=content-type:application/json"   http://${BTInfra_T00_S01_btinfra_bugletService}/api/v1/messages/publish

rm -f ${post}.*


exit

:bat
cd /d %~dp0

set tid=%1
set name=%2
set type=%3
set description=%4
set post=%name%-%tid%-%type%
echo {"from":"btinfra_sgmanagerService@T00","fromName":"btinfra_sgmanagerService","to":["%tid%"],"msgType":"3","ttl":"436800","severity":0,"taskType":"%type%","taskId":"%name%","title":"%description%","content":"%description%"} >%post%.gbk
%launchPath%\helper\iconv -f GBK -t UTF-8 %post%.gbk >%post%.utf8

%launchPath%\helper\wget -O %post%.response -S  --post-file=%post%.utf8 "--header=content-type:application/json"   http://%BTInfra_T00_S01_btinfra_bugletService%/api/v1/messages/publish

del %post%.*

